App({
    globalData: {
        navHeight: "",
        navTop: "",
        windowHeight: "",
    },
    onLaunch: function () {
        wx.loadFontFace({
            family: 'PingFangSC-Medium',
            source: 'url("https://www.bjsjyx.com.cn/xianxi.tff")',
            success: function () {
                console.log('load font success')
            },
            fail: (e) => {
                console.log(e);
            }
        })
        let menuButtonObject = wx.getMenuButtonBoundingClientRect();
        wx.getSystemInfo({
            success: res => {
                //导航高度
                let statusBarHeight = res.statusBarHeight,
                    navTop = menuButtonObject.top,
                    navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight) * 2;
                this.globalData.navHeight = navHeight;
                this.globalData.navTop = navTop;
                this.globalData.windowHeight = res.windowHeight;
            },
            fail(err) {
                console.log(err);
            }
        })
        this.checkPageInfo()
    },
    /**
     * 检测本地是否有token，没有就提示未登录，点击跳转到登录页面
     */
    checkPageInfo() {
        // let token = wx.getStorageSync("token");
        // if (!token) {
        //   // 未登录，跳转到登录页面
        //   wx.showModal({
        //     title: '温馨提示',
        //     content: '您还未登录',
        //     showCancel: false,
        //     confirmText: '去登录',
        //     success: (result) => {
        //       if (result.confirm) {
        //         wx.redirectTo({
        //           url: '/pages/loginHome/index',
        //         })
        //       }
        //     }
        //   });
        // }
    },
    onShareAppMessage(){
        wx.showShareMenu({
            withShareTicket:true,
            menu:['shareAppMessage','shareTimeLine']
        })
    },
    onShareTimeline(){},
})